import * as THREE from "three"
import funcUtil from "../utils/func.util"
import a from "../shader/31090"
import l from "../shader/69383"
import ae from "../shader/79826"
import be from "../shader/64715"
import ce from "../shader/55546"
import de from "../shader/96228"
import renderOrderEnum from "../enum/renderOrder.enum"
const h = {
  basicTextured: {
    uniforms: {
      tDiffuse: { type: "t", value: null },
      alpha: { type: "f", value: 1 }
    },
    vertexShader: funcUtil.addNR(l, ae),
    fragmentShader: funcUtil.addNR(a, be)
  },
  screenSpaceColored: {
    uniforms: {
      color: { type: "v3", value: new THREE.Vector3(0, 0, 0) },
      opacity: { type: "f", value: 1 }
    },
    vertexShader: funcUtil.addNR(l, ce),
    fragmentShader: funcUtil.addNR(a, de)
  }
}
export default class ScreenOverlayMesh extends THREE.Mesh<THREE.PlaneBufferGeometry, THREE.RawShaderMaterial> {
  _opacity: number
  constructor(e) {
    super(
      new THREE.PlaneBufferGeometry(2, 2, 1, 1),
      new THREE.RawShaderMaterial({
        uniforms: THREE.UniformsUtils.clone(h.screenSpaceColored.uniforms),
        vertexShader: h.screenSpaceColored.vertexShader,
        fragmentShader: h.screenSpaceColored.fragmentShader,
        transparent: !0,
        depthTest: !1,
        depthWrite: !1
      })
    )
    this._opacity = 1
    this.material.uniforms.color.value = new THREE.Color(e)
    this.renderOrder = renderOrderEnum.colorOverlay
    this.name = "ScreenOverlayMesh"
  }
  set opacity(e) {
    this.visible = e > 0
    this._opacity = e
    this.material.uniforms.opacity.value = e
  }
  get opacity() {
    return this._opacity
  }
  dispose() {
    this.material.dispose()
    this.geometry.dispose()
  }
}
